package com.imedway.ihe.dtz.xds.conf;

import javax.xml.ws.Endpoint;

import org.apache.cxf.Bus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.imedway.ihe.dtz.xds.service.XdsRegistryService;
import com.imedway.ihe.dtz.xds.service.XdsRepositoryService;
import com.imedway.ihe.dtz.xds.service.impl.XdsRepository;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * @author zhongyj <1126834403@qq.com><br/>
 * @date 2024/7/2
 */
@Slf4j
@Configuration
@RequiredArgsConstructor
public class XdsCxfConfig {
	
    private final Bus bus;
    private final XdsRegistryService xdsRegistryService;
    private final XdsRepositoryService xdsRepositoryService;

    @SuppressWarnings("all")
    @Bean
    public ServletRegistrationBean disServlet() {
        return new ServletRegistrationBean(new CXFServlet(), "/services/*");
    }

    @Bean
    public Endpoint xdsRegistryService() {
        EndpointImpl endpoint = new EndpointImpl(bus, xdsRegistryService);
        endpoint.publish("/xdsRegistryService");
        return endpoint;
    }
    @Bean
    public Endpoint xdsRepositoryService() {
        EndpointImpl endpoint = new EndpointImpl(bus, xdsRepositoryService);
        endpoint.publish("/xdsRepositoryService");
        return endpoint;
    }
  
}
